//
//  SLMsgTableViewCell.m
//  StarLight
//
//  Created by 吴涛 on 16/6/6.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLMsgTableViewCell.h"

@interface SLMsgTableViewCell ()

@property (weak, nonatomic) IBOutlet UIView *backView;
@property (weak, nonatomic) IBOutlet UILabel *titleLB;
@property (weak, nonatomic) IBOutlet UIButton *deletBtn;
@property (weak, nonatomic) IBOutlet UILabel *contentLB;
@property (weak, nonatomic) IBOutlet UILabel *timeLB;

@property (nonatomic, strong) SLMessageModel *msgModel;

@end


@implementation SLMsgTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
  self.selectionStyle = UITableViewCellSelectionStyleNone;

  self.contentView.backgroundColor  = [UIColor defeutBackgroudColor];
  self.backView.backgroundColor = [UIColor whiteColor];
  self.backView.layer.cornerRadius = 5;
  self.titleLB.textColor = SLYellowColor;
  
  UIView *line = [UIView lineView];
  [self.backView addSubview:line];
  [line mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.equalTo(self.backView);
    make.height.equalTo(@0.5);
    make.top.equalTo(self.titleLB.mas_bottom).offset(3);
  }];
  
  UIView *line2 = [UIView lineView];
  [self.backView addSubview:line2];
  [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.right.equalTo(self.backView);
    make.height.equalTo(@0.5);
    make.top.equalTo(self.contentLB.mas_bottom).offset(3);
  }];
  
}


#pragma mark - Public Methods

- (void)configMsgCellWithModel:(SLMessageModel *)msgModel{
  self.msgModel = msgModel;
  self.contentLB.text = msgModel.content;
  self.timeLB.text = msgModel.time;
  
  [self setTitleWithType:msgModel.type];
}


#pragma mark - Private Methods

- (IBAction)deletAction:(id)sender{
  
  if (_delegate && [_delegate respondsToSelector:@selector(didtapedMsgCellDeletBtn:)]) {
    [_delegate didtapedMsgCellDeletBtn:self.msgModel];
  }
  
  
}

- (void)setTitleWithType:(NSString *)type{
  if ([type isEqualToString:@"0"]) {
    self.titleLB.text = @"系统提示";
  }else if ([type isEqualToString:@"1"]) {
    self.titleLB.text = @"货物消息";
  }else if ([type isEqualToString:@"2"]) {
    self.titleLB.text = @"船舶消息";
  }else if ([type isEqualToString:@"3"]) {
    self.titleLB.text = @"网页消息";
  }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
